package com.example.listener.service;

import com.example.listener.event.MyEvent;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationContext;
import org.springframework.stereotype.Service;

@Service
public class MyEventService {

    @Autowired
    private ApplicationContext applicationContext;

    public void addEvent(String eventName) {
        // 发布事件
        MyEvent event = new MyEvent(this, eventName);
        applicationContext.publishEvent(event);
    }
}
